package cn.com.tt.flink.sql.engine.pojo.source;

import lombok.Data;

import java.util.List;
import java.util.Optional;

@Data
public class JobSource {
    private String sourceId;
    private String jobName;
    private String tableName;
    private List<SourceField> fieldsList;
    private List<SourceProperty> propertyList;

    public String getConnectorType() throws Exception {
        Optional<String> connector = propertyList.stream()
                .filter(p -> p.getPropKey().equals("connector"))
                .map(SourceProperty::getPropValue)
                .findFirst();

        return connector.orElseThrow(()->new Exception(tableName+"缺少connector属性"));
    }
}
